package cn.sczhyt.modules.szhy.controller;

import java.util.Arrays;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.sczhyt.modules.szhy.entity.MeetingLeaveEntity;
import cn.sczhyt.modules.szhy.service.MeetingLeaveService;
import cn.sczhyt.common.utils.R;



/**
 * 会议请假表
 *
 * @author luojialin
 * @email 78357966@qq.com
 * @date 2021-04-29 16:32:37
 */
@RestController
@RequestMapping("szhy/meetingleave")
public class MeetingLeaveController {
    @Autowired
    private MeetingLeaveService meetingLeaveService;

    /**
     * 请假人列表
     */
    @RequestMapping("/list/{meetingId}")
    public R list(@PathVariable String meetingId){
        QueryWrapper<MeetingLeaveEntity> queryWrapper = new QueryWrapper<MeetingLeaveEntity>()
                .eq("meeting_id",meetingId);

        List<MeetingLeaveEntity> list = meetingLeaveService.list(queryWrapper);

        return R.ok().put("data", list);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{leaveId}")
    public R info(@PathVariable("leaveId") String leaveId){
		MeetingLeaveEntity meetingLeave = meetingLeaveService.getById(leaveId);

        return R.ok().put("meetingLeave", meetingLeave);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody MeetingLeaveEntity meetingLeave){
		meetingLeaveService.save(meetingLeave);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody MeetingLeaveEntity meetingLeave){
		meetingLeaveService.updateById(meetingLeave);

        return R.ok();
    }



    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] leaveIds){
		meetingLeaveService.removeByIds(Arrays.asList(leaveIds));

        return R.ok();
    }



}
